local skel = fk.CreateSkill {
  name = "#assault_rifle_skill",
  attached_equip = "assault_rifle",
}

skel:addEffect(fk.TargetSpecified, {
  anim_type = "offensive",
  priority = 0.1,
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(skel.name) then
      local to = data.to
      return data.card.trueName == "slash" and not to.dead and to ~= player and data:isOnlyTarget(to)
      and not player:isKongcheng() and player:getMark("@ARbullet") > 0
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local to = data.to
    -- 无敌了，还要判这个
    local ids = table.filter(player:getCardIds("h"), function (id)
      if Fk:getCardById(id).color ~= Card.Black then return false end
      local slash = Fk:cloneCard("slash")
      slash:addSubcard(id)
      slash.skillName = skel.name
      return not player:prohibitUse(slash) and not player:isProhibited(to, slash)
    end)
    local cards = room:askToCards(player, {
      min_num = 1, max_num = 1, cancelable = true, skill_name = skel.name, pattern = tostring(Exppattern{ id = ids }),
      prompt = "#assault_rifle-slash:"..to.id
    })
    if #cards > 0 then
      event:setCostData(self, cards)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:removePlayerMark(player, "@ARbullet")
    room:useVirtualCard("slash", event:getCostData(self), player, data.to, skel.name, true)
  end,
})

skel:addEffect(fk.TurnEnd, {
  priority = 0.1,
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name)
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player.room:addPlayerMark(player, "@ARbullet")
  end,
})

Fk:loadTranslationTable{
  ["#assault_rifle_skill"] = "突击步枪",
  ["@ARbullet"] = "子弹",
  ["#assault_rifle-slash"] = "突击步枪：可以消耗1枚子弹，将一张黑色手牌当【杀】对%src使用",
}

return skel
